package com.anyou.mall.pla.service.impl;

import java.util.List;

import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.utils.DateUtils;
import com.anyou.mall.pla.mapper.PlaReportTypeMapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.beanutils.ConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.anyou.mall.pla.mapper.UseUserGoodsReportMapper;
import com.anyou.mall.pla.domain.UseUserGoodsReport;
import com.anyou.mall.pla.service.IUseUserGoodsReportService;

/**
 * 举报管理Service业务层处理
 *
 * @author xq
 * @date 2022-04-30
 */
@Service
public class UseUserGoodsReportServiceImpl implements IUseUserGoodsReportService
{
    @Autowired
    private UseUserGoodsReportMapper useUserGoodsReportMapper;

    @Autowired
    private PlaReportTypeMapper plaReportTypeMapper;

    /**
     * 查询举报管理
     *
     * @param reportId 举报管理主键
     * @return 举报管理
     */
    @Override
    public UseUserGoodsReport selectUseUserGoodsReportByReportId(Long reportId)
    {
        return useUserGoodsReportMapper.selectUseUserGoodsReportByReportId(reportId);
    }

    /**
     * 查询举报管理列表
     *
     * @param useUserGoodsReport 举报管理
     * @return 举报管理
     */
    @Override
    public List<UseUserGoodsReport> selectUseUserGoodsReportList(UseUserGoodsReport useUserGoodsReport)
    {
        return useUserGoodsReportMapper.selectUseUserGoodsReportList(useUserGoodsReport);
    }

    @Override
    public ApiResult status(String reportId) {

        Long[] reportIds=(Long[]) ConvertUtils.convert(reportId,Long.class);
        for (Long id : reportIds) {
            useUserGoodsReportMapper.update(null,new LambdaUpdateWrapper<UseUserGoodsReport>()
                    .set(UseUserGoodsReport::getHandleStatus,2)
                    .eq(UseUserGoodsReport::getReportId,id));
        }
        return ApiResult.success(1);
    }

    /**
     * 新增举报管理
     *
     * @param useUserGoodsReport 举报管理
     * @return 结果
     */
    @Override
    public int insertUseUserGoodsReport(UseUserGoodsReport useUserGoodsReport)
    {
        useUserGoodsReport.setCreateTime(DateUtils.getNowDate());
        return useUserGoodsReportMapper.insertUseUserGoodsReport(useUserGoodsReport);
    }

    /**
     * 修改举报管理
     *
     * @param useUserGoodsReport 举报管理
     * @return 结果
     */
    @Override
    public int updateUseUserGoodsReport(UseUserGoodsReport useUserGoodsReport)
    {
        useUserGoodsReport.setUpdateTime(DateUtils.getNowDate());
        return useUserGoodsReportMapper.updateUseUserGoodsReport(useUserGoodsReport);
    }

    /**
     * 批量删除举报管理
     *
     * @param reportIds 需要删除的举报管理主键
     * @return 结果
     */
    @Override
    public int deleteUseUserGoodsReportByReportIds(Long[] reportIds)
    {
        return useUserGoodsReportMapper.deleteUseUserGoodsReportByReportIds(reportIds);
    }

    /**
     * 删除举报管理信息
     *
     * @param reportId 举报管理主键
     * @return 结果
     */
    @Override
    public int deleteUseUserGoodsReportByReportId(Long reportId)
    {
        return useUserGoodsReportMapper.deleteUseUserGoodsReportByReportId(reportId);
    }
}
